/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.gui.config;

import nfse.gui.client.NetFSEClient;
import nfse.gui.client.QueryService;
import nfse.gui.config.*;
import nfse.gui.query.TypeInfo;
import nfse.gui.util.GUIUtil;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.*;
import com.gwtext.client.widgets.MessageBox;
import nfse.gui.query.TypeInfo;

public class SensorConfigTable extends FlexTable implements PopupListener {

    private SyslogConfigDialogBox confDialog = new SyslogConfigDialogBox();

    private NetFlowConfigDialogBox netflowConfDialog = new NetFlowConfigDialogBox(this);

    private SensorDialogBox sensorDialog = new SensorDialogBox();

    private SensorInfo selectedSensor = null;

    private SyslogConfig selectedSyslogConfig = null;

    private NetFlowConfig selectedNetFlowConfig = null;

    FlexTable sensorTable = new FlexTable();

    FlexTable sensorActionTable = new FlexTable();

    FlexTable syslogConfigActionTable = new FlexTable();

    FlexTable syslogConfigTable = new FlexTable();

    FlexTable netflowConfigActionTable = new FlexTable();

    FlexTable netflowConfigTable = new FlexTable();

  

   

    private RadioButton[] syslogRadioButtons = new RadioButton[0];

    private RadioButton[] netflowRadioButtons = new RadioButton[0];

    private RadioButton[] sensorRadioButtons = new RadioButton[0];

    public SensorConfigTable() {

        this.confDialog.addPopupListener(this);
        this.sensorDialog.addPopupListener(this);

        Hyperlink netflowAddLink = new Hyperlink("Add", "AddNetFlow");
        netflowAddLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                netflowConfDialog.setTitle("Add NetFlow Configuration");
                netflowConfDialog.set(new NetFlowConfig());
                netflowConfDialog.setNew(true);
                netflowConfDialog.show();
            }
        });

        Hyperlink netflowEditLink = new Hyperlink("Edit", "EditNetFlow");
        netflowEditLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                if (selectedSensor != null) {
                    netflowConfDialog.setTitle("Edit NetFlow Configuration");
                    netflowConfDialog.setNew(false);
                    netflowConfDialog.set(selectedNetFlowConfig);
                    netflowConfDialog.show();
                }
            }
        });

        Hyperlink netflowDeleteLink = new Hyperlink("Delete", "DeleteNetFlow");
        netflowDeleteLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                if (selectedNetFlowConfig != null)
                    deleteNetFlowConfig(selectedNetFlowConfig);
            }
        });

        netflowConfigActionTable.setWidget(0, 0, new Label("Actions: "));
        netflowConfigActionTable.setWidget(0, 1, netflowAddLink);
        netflowConfigActionTable.setHTML(0, 2, "|");
        netflowConfigActionTable.setWidget(0, 3, netflowEditLink);
        netflowConfigActionTable.setHTML(0, 4, "|");
        netflowConfigActionTable.setWidget(0, 5, netflowDeleteLink);

        Hyperlink syslogAddLink = new Hyperlink("Add", "AddSyslog");
        syslogAddLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                confDialog.setText("Add Syslog Configuration");
                confDialog.set(new SyslogConfig());
                confDialog.setNew(true);
                confDialog.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
                confDialog.show();
            }
        });

        Hyperlink syslogEditLink = new Hyperlink("Edit", "EditSyslog");
        syslogEditLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                if (selectedSensor != null) {
                    confDialog.setText("Edit Syslog Configuration");
                    confDialog.setNew(false);
                    confDialog.set(selectedSyslogConfig);
                    confDialog.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
                    confDialog.show();
                }
            }
        });

        Hyperlink syslogDeleteLink = new Hyperlink("Delete", "DeleteSyslog");
        syslogDeleteLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                if (selectedSyslogConfig != null)
                    deleteSyslogConfig(selectedSyslogConfig);
            }
        });

        syslogConfigActionTable.setWidget(0, 0, new Label("Actions: "));
        syslogConfigActionTable.setWidget(0, 1, syslogAddLink);
        syslogConfigActionTable.setHTML(0, 2, "|");
        syslogConfigActionTable.setWidget(0, 3, syslogEditLink);
        syslogConfigActionTable.setHTML(0, 4, "|");
        syslogConfigActionTable.setWidget(0, 5, syslogDeleteLink);

        Hyperlink sensorAddLink = new Hyperlink("Add", "AddSensor");
        sensorAddLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                sensorDialog.setText("Add Sensor");
                sensorDialog.set(new SensorInfo());
                sensorDialog.setNew(true);
                sensorDialog.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
                sensorDialog.show();
            }
        });

        Hyperlink sensorDeleteLink = new Hyperlink("Delete", "DeleteSensor");
        sensorDeleteLink.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                if (selectedSensor != null)
                    deleteSensor(selectedSensor.id);
            }
        });

        sensorActionTable.setWidget(0, 0, new Label("Actions: "));
        sensorActionTable.setWidget(0, 1, sensorAddLink);
        sensorActionTable.setHTML(0, 2, "|");
        sensorActionTable.setWidget(0, 3, sensorDeleteLink);

        int idx = -1;
       
        this.setHTML(++idx, 0, "<b>Sensors</b>");
        this.setWidget(++idx, 0, sensorActionTable);
        this.setWidget(++idx, 0, sensorTable);
        this.setHTML(++idx, 0, "<hr>");
        this.setHTML(++idx, 0, "<b>Syslog Configuration</b>");
        this.setWidget(++idx, 0, syslogConfigActionTable);
        this.setWidget(++idx, 0, syslogConfigTable);
        this.setHTML(++idx, 0, "<hr>");
        this.setHTML(++idx, 0, "<b>NetFlow Configuration</b>");
        this.setWidget(++idx, 0, netflowConfigActionTable);
        this.setWidget(++idx, 0, netflowConfigTable);

        refresh();
    }

    public void setTypes(TypeInfo typeInfo) {
        this.sensorDialog.setTypes(typeInfo);
    }

    public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
        try {
            SyslogConfigDialogBox conf = (SyslogConfigDialogBox) sender;
            if (!conf.isCancelled()) {
                SyslogConfig syslogConfig = conf.getSyslogConfig();
                if (conf.isNew()) {
                    addSyslogConfig(syslogConfig, sender);
                } else {
                    editSyslogConfig(syslogConfig, sender);
                }
                syslogConfigs();
            }

        } catch (ClassCastException cce) {

        }

       

        try {
            SensorDialogBox sensorDialog = (SensorDialogBox) sender;
            if (!sensorDialog.isCancelled()) {
                SensorInfo info = sensorDialog.getSensorInfo();
                if (sensorDialog.isNew()) {
                    addSensorInfo(info);
                } else {

                }
                sensorInfo();
            }

        } catch (ClassCastException cce) {

        }

    }

    private void sensorInfo() {

        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                updateSensorInfo((SensorInfo[]) result);
            }
        };

        nfseService.getSensorInfo(callback);

    }

    

    private void updateSensorInfo(SensorInfo[] info) {

        this.netflowConfDialog.setSensors(info);
        this.confDialog.setSensors(info);

        if (info.length == 0) {
            while (sensorTable.getRowCount() > 1) {
                sensorTable.removeRow(1);
            }
            sensorTable.setHTML(0, 0, "No sensors have been created. Click Add above to create a sensor. <br>"
                    + "At least one sensor must be created before syslog and NetFlow can be configured.");
            return;
        }

        int numRows = info.length + 1;
        while (sensorTable.getRowCount() > numRows) {
            sensorTable.removeRow(numRows);
        }

        sensorTable.addStyleName("nfsetable");
        sensorTable.addStyleName("nfsetbody");
        sensorTable.setHTML(0, 0, "");
        sensorTable.setHTML(0, 1, "<b>Sensor</b>");
        sensorTable.setHTML(0, 2, "<b>Type</b>");
        sensorTable.getRowFormatter().setStyleName(0, "nfseth");

        selectedSensor = null;

        sensorRadioButtons = new RadioButton[info.length];

        for (int i = 0; i < info.length; i++) {

            if (i % 2 == 0) {
                sensorTable.getRowFormatter().addStyleName(i + 1, "nfsetr");
            } else {
                sensorTable.getRowFormatter().addStyleName(i + 1, "nfsetrodd");
            }

            final SensorInfo temp = info[i];
            sensorRadioButtons[i] = new RadioButton("sensors");
            if (i == 0) {
                sensorRadioButtons[i].setChecked(true);
                selectedSensor = info[i];
            }
            sensorRadioButtons[i].addClickListener(new ClickListener() {
                public void onClick(Widget sender) {
                    selectedSensor = temp;
                }
            });
            sensorTable.setWidget(i + 1, 0, sensorRadioButtons[i]);
            sensorTable.getCellFormatter().addStyleName(i + 1, 0, "nfsetd");
            sensorTable.setHTML(i + 1, 1, info[i].sensorName);
            sensorTable.getCellFormatter().addStyleName(i + 1, 1, "nfsetd");
            sensorTable.setHTML(i + 1, 2, info[i].typeName);
            sensorTable.getCellFormatter().addStyleName(i + 1, 2, "nfsetd");
        }
    }

    
    private void syslogConfigs() {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                updateSyslogConfigs((SyslogConfig[]) result);
            }
        };

        nfseService.getSyslogConfigs(callback);

    }

    

    private void editSyslogConfig(SyslogConfig config, Widget sender) {
        final Widget tempSender = sender;
        final int sensorID = config.sensor;

        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                NetFSEClient.showGenericDialog("Syslog Configuration Change", (String) result, tempSender);
                restartSyslog(sensorID);
                syslogConfigs();
            }
        };

        nfseService.editSyslogConfig(config, callback);
    }

   

    private void addSyslogConfig(SyslogConfig config, Widget sender) {
        final Widget tempSender = sender;
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        final SyslogConfig tempConfig = config;

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                NetFSEClient.showGenericDialog("Syslog Configuration Change", (String) result, tempSender);
                startSyslog(tempConfig.sensor);
                syslogConfigs();
            }
        };

        nfseService.addSyslogConfig(config, callback);
    }

    private void startSyslog(int sensorID) {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                // NetFSEClient.showGenericDialog("Syslog Configuration
                // Change",(String) result);
            }
        };

        nfseService.syslogAndNetFlowControl(sensorID, 4, callback);
    }

    private void restartSyslog(int sensorID) {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                // NetFSEClient.showGenericDialog("Syslog Configuration
                // Change",(String) result);
            }
        };

        nfseService.syslogAndNetFlowControl(sensorID, 6, callback);
    }

    private void stopSyslog(int sensorID) {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                // NetFSEClient.showGenericDialog("Syslog Configuration
                // Change",(String) result);
            }
        };

        nfseService.syslogAndNetFlowControl(sensorID, 5, callback);
    }

    private void addSensorInfo(SensorInfo info) {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                NetFSEClient.showGenericDialog("Sensor Configuration Change", (String) result);
                sensorInfo();
            }
        };

        nfseService.addSensor(info, callback);
    }

    public void netflowConfigs() {
        ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
        endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

        AsyncCallback callback = new AsyncCallback() {
            public void onFailure(Throwable caught) {
                NetFSEClient.redirect("NetFSEClient.html");
            }

            public void onSuccess(Object result) {
                updateNetFlowConfigs((NetFlowConfig[]) result);
            }
        };

        nfseService.getNetFlowConfigs(callback);

    }

    private void updateSyslogConfigs(SyslogConfig[] configs) {

        if (configs.length == 0) {
            while (syslogConfigTable.getRowCount() > 0) {
                syslogConfigTable.removeRow(0);
            }

            syslogConfigTable.setHTML(0, 0,
                    "No syslog configurations exist. Click Add above to create a syslog configuration.");
            return;
        }

        int numRows = configs.length + 1;
        while (syslogConfigTable.getRowCount() > numRows) {
            syslogConfigTable.removeRow(numRows);
        }

        syslogConfigTable.setStyleName("nfsetable");
        syslogConfigTable.addStyleName("nfsetbody");

        syslogConfigTable.setHTML(0, 0, "");
        syslogConfigTable.setHTML(0, 1, "<b>Sensor</b>");
        syslogConfigTable.setHTML(0, 2, "<b>Tag</b>");
        syslogConfigTable.setHTML(0, 3, "<b>File Path</b>");
        syslogConfigTable.setHTML(0, 4, "<b>IP</b>");
        syslogConfigTable.getRowFormatter().setStyleName(0, "nfseth");

        selectedSyslogConfig = null;

        syslogRadioButtons = new RadioButton[configs.length];

        for (int i = 0; i < configs.length; i++) {

            if (i % 2 == 0) {
                syslogConfigTable.getRowFormatter().addStyleName(i + 1, "nfsetr");
            } else {
                syslogConfigTable.getRowFormatter().addStyleName(i + 1, "nfsetrodd");
            }

            final SyslogConfig config = configs[i];
            syslogRadioButtons[i] = new RadioButton("syslog");
            if (i == 0) {
                syslogRadioButtons[i].setChecked(true);
                selectedSyslogConfig = configs[i];
            }
            syslogRadioButtons[i].addClickListener(new ClickListener() {
                public void onClick(Widget sender) {
                    selectedSyslogConfig = config;
                }
            });
            syslogConfigTable.setWidget(i + 1, 0, syslogRadioButtons[i]);
            syslogConfigTable.getCellFormatter().addStyleName(i + 1, 0, "nfsetd");
            syslogConfigTable.setHTML(i + 1, 1, configs[i].sensorName);
            syslogConfigTable.getCellFormatter().addStyleName(i + 1, 1, "nfsetd");
            syslogConfigTable.setHTML(i + 1, 2, configs[i].keyword);
            syslogConfigTable.getCellFormatter().addStyleName(i + 1, 2, "nfsetd");
            syslogConfigTable.setHTML(i + 1, 3, configs[i].filePath);
            syslogConfigTable.getCellFormatter().addStyleName(i + 1, 3, "nfsetd");
            if (configs[i].ip.length() > 0)
                syslogConfigTable.setHTML(i + 1, 4, configs[i].ip);
            else
                syslogConfigTable.setHTML(i + 1, 4, "-");
            syslogConfigTable.getCellFormatter().addStyleName(i + 1, 4, "nfsetd");
        }
    }

    private void updateNetFlowConfigs(NetFlowConfig[] configs) {

        if (configs.length == 0) {
            while (netflowConfigTable.getRowCount() > 0) {
                netflowConfigTable.removeRow(0);
            }

            netflowConfigTable.setHTML(0, 0,
                    "No NetFlow configurations exist. Click Add above to create a NetFlow configuration.");
            return;
        }

        int numRows = configs.length + 1;
        while (netflowConfigTable.getRowCount() > numRows) {
            netflowConfigTable.removeRow(numRows);
        }

        netflowConfigTable.setStyleName("nfsetable");
        netflowConfigTable.addStyleName("nfsetbody");

        netflowConfigTable.setHTML(0, 0, "");
        netflowConfigTable.setHTML(0, 1, "<b>Sensor</b>");
        netflowConfigTable.setHTML(0, 2, "<b>Port</b>");
        netflowConfigTable.getRowFormatter().setStyleName(0, "nfseth");

        selectedNetFlowConfig = null;

        netflowRadioButtons = new RadioButton[configs.length];

        for (int i = 0; i < configs.length; i++) {
            final NetFlowConfig config = configs[i];

            if (i % 2 == 0) {
                netflowConfigTable.getRowFormatter().addStyleName(i + 1, "nfsetr");
            } else {
                netflowConfigTable.getRowFormatter().addStyleName(i + 1, "nfsetrodd");
            }

            netflowRadioButtons[i] = new RadioButton("netflow");
            if (i == 0) {
                netflowRadioButtons[i].setChecked(true);
                selectedNetFlowConfig = configs[i];
            }
            netflowRadioButtons[i].addClickListener(new ClickListener() {
                public void onClick(Widget sender) {
                    selectedNetFlowConfig = config;
                }
            });
            netflowConfigTable.setWidget(i + 1, 0, netflowRadioButtons[i]);
            netflowConfigTable.getCellFormatter().addStyleName(i + 1, 0, "nfsetd");
            netflowConfigTable.setHTML(i + 1, 1, configs[i].sensorName);
            netflowConfigTable.getCellFormatter().addStyleName(i + 1, 1, "nfsetd");
            netflowConfigTable.setHTML(i + 1, 2, configs[i].port + "");
            netflowConfigTable.getCellFormatter().addStyleName(i + 1, 2, "nfsetd");
            netflowConfigTable.getCellFormatter().addStyleName(i + 1, 2, "tdright");
        }
    }

    private synchronized void deleteSyslogConfig(SyslogConfig config) {
        final int sensorID = config.sensor;
        final SyslogConfig tempConfig = config;
        MessageBox.confirm("Confirm", "Are you sure you want to delete the selected Syslog configuration?",
                new MessageBox.ConfirmCallback() {
                    public void execute(String btnID) {
                        if (btnID.equals("yes")) {
                            ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

                            ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
                            endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

                            AsyncCallback callback = new AsyncCallback() {
                                public void onFailure(Throwable caught) {
                                    NetFSEClient.redirect("NetFSEClient.html");
                                }

                                public void onSuccess(Object result) {
                                    syslogConfigs();
                                    stopSyslog(sensorID);
                                }
                            };

                            nfseService.deleteSyslogConfig(tempConfig, callback);
                        }
                    }
                });

    }

    private synchronized void deleteNetFlowConfig(NetFlowConfig config) {
        final NetFlowConfig tempConfig = config;
        MessageBox.confirm("Confirm", "Are you sure you want to delete the selected NetFlow configuration?",
                new MessageBox.ConfirmCallback() {
                    public void execute(String btnID) {
                        if (btnID.equals("yes")) {
                            ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

                            ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
                            endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

                            AsyncCallback callback = new AsyncCallback() {
                                public void onFailure(Throwable caught) {
                                    NetFSEClient.redirect("NetFSEClient.html");
                                }

                                public void onSuccess(Object result) {
                                    netflowConfigs();
                                    MessageBox
                                            .alert("NetFlow configuration change succeeded. Changes will take effect when the Net/FSE server is restarted.");
                                }
                            };

                            nfseService.deleteNetFlowConfig(tempConfig, callback);
                        }
                    }
                });

    }

    private synchronized void deleteSensor(int sensor) {
        final int tempSensor = sensor;
        MessageBox.confirm("Confirm", "Are you sure you want to delete the selected sensor entry?",
                new MessageBox.ConfirmCallback() {
                    public void execute(String btnID) {
                        if (btnID.equals("yes")) {
                            ConfigServiceAsync nfseService = (ConfigServiceAsync) GWT.create(ConfigService.class);

                            ServiceDefTarget endpoint = (ServiceDefTarget) nfseService;
                            endpoint.setServiceEntryPoint(NetFSEClient.CONFIG_URL);

                            AsyncCallback callback = new AsyncCallback() {
                                public void onFailure(Throwable caught) {
                                    NetFSEClient.redirect("NetFSEClient.html");
                                }

                                public void onSuccess(Object result) {
                                    sensorInfo();
                                    MessageBox
                                            .alert("Sensor configuration change succeeded. Changes will take effect when the Net/FSE server is restarted.");
                                }
                            };

                            nfseService.deleteSensor(tempSensor, callback);
                        }
                    }
                });

    }

    public void refresh() {
        //recordCounts();
        sensorInfo();
        syslogConfigs();
        netflowConfigs();
    }

}
